package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.domain.SuccessCode;
import com.atguigu.jxc.entity.SaleList;
import com.atguigu.jxc.service.SaleListGoodsService;
import javafx.concurrent.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;


@RestController
@RequestMapping("/saleListGoods")
public class SaleListGoodsController {
    @Autowired
    private SaleListGoodsService saleListGoodsService;

    /**
     * @description:  销售单保存
     * localhost:8080/saleListGoods/save?saleNumber=XS1605772263999
     * http://localhost:8080/saleListGoods/save?saleNumber=XS1676029121427
     * @param:  saleList
                saleListGoodsStr
     * @return: com.atguigu.jxc.domain.ServiceVO
     * @author hxy
     *SaleList saleList, String saleListGoodsStr
     * @date: 2023/2/10 11:31
     */
    @RequestMapping("save")
    public ServiceVO save (SaleList saleList,
                           String saleListGoodsStr){

        return saleListGoodsService.save(saleList,saleListGoodsStr);

    }

    
    /** 
     * @description:  销售单查询（可查询条件：销售单号、客户、付款状态）
     * 请求URL：http://localhost:8080/saleListGoods/list
     * @param: saleNumber
    customerId
    state
    sTime
    eTime 
     * @return: java.util.Map<java.lang.String,java.lang.Object> 
     * @author hxy
     * @date: 2023/2/10 16:40
     */ 
    @RequestMapping("list")
    public Map<String,Object> list (String saleNumber,
                                    Integer customerId,
                                    Integer state,
                                    String sTime,
                                    String eTime){

        return saleListGoodsService.list(saleNumber, customerId, state, sTime, eTime);

    }
    /** 
     * @description:销售单商品信息
     * http://localhost:8080/saleListGoods/goodsList
     * @param: saleListId 
     * @return: java.util.Map<java.lang.String,java.lang.Object> 
     * @author hxy
     * @date: 2023/2/11 9:09
     */ 
    @RequestMapping("goodsList")
    public Map<String,Object> goodsList(Integer saleListId){
        return saleListGoodsService.goodsList(saleListId);
    }
    /**
     * @description:删除销售单
     * http://localhost:8080/saleListGoods/delete
     * @param: saleListId 
     * @return: com.atguigu.jxc.domain.ServiceVO 
     * @author hxy
     * @date: 2023/2/11 9:15
     */ 
    @RequestMapping("delete")
    public ServiceVO delete(Integer saleListId){
        return saleListGoodsService.delete(saleListId);
    }

}
